// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.startup.importSettings.transfer.backend.providers.vscode.mappings

import com.intellij.openapi.actionSystem.IdeActions

object KeyBindingsMappings {
  fun commandIdMap(commandId: String): String? = when (commandId) {
    "actions.find" -> "Find"
    "cursorBottom" -> "EditorTextEnd"
    "cursorEnd" -> "EditorLineEnd"
    "cursorHome" -> "EditorLineStart"
    "cursorTop" -> "EditorTextStart"
    "editor.action.addCommentLine" -> "CommentByLineComment"
    "editor.action.addSelectionToNextFindMatch" -> "SelectNextOccurrence"
    "editor.action.blockComment" -> "CommentByBlockComment"
    "editor.action.changeAll" -> "SelectAllOccurrences"
    "editor.action.clipboardCopyAction" -> IdeActions.ACTION_COPY
    "editor.action.clipboardCutAction" -> "\$Cut"
    "editor.action.clipboardPasteAction" -> "\$Paste"
    "editor.action.commentLine" -> "CommentByLineComment"
    "editor.action.copyLinesDownAction" -> "EditorDuplicate"
    "editor.action.deleteLines" -> "EditorDeleteLine"
    "editor.action.formatDocument" -> "ReformatCode"
    "editor.action.goToReferences" -> "ShowUsages"
    "editor.action.indentLines" -> "EditorIndentLineOrSelection"
    "editor.action.insertCursorAbove" -> "EditorCloneCaretAbove"
    "editor.action.insertCursorAtEndOfEachLineSelected" -> "EditorToggleColumnMode"
    "editor.action.insertCursorBelow" -> "EditorCloneCaretBelow"
    "editor.action.insertLineAfter" -> "EditorStartNewLine"
    "editor.action.insertLineBefore" -> "EditorStartNewLineBefore"
    "editor.action.jumpToBracket" -> "EditorMatchBrace"
    "editor.action.marker.nextInFiles" -> "GotoNextError"
    "editor.action.marker.prevInFiles" -> "GotoPreviousError"
    "editor.action.moveLinesDownAction" -> "MoveLineDown"
    "editor.action.moveLinesUpAction" -> "MoveLineUp"
    "editor.action.outdentLines" -> "EditorUnindentSelection"
    "editor.action.peekDefinition" -> "QuickImplementations"
    "editor.action.quickFix" -> "ShowIntentionActions"
    "editor.action.removeCommentLine" -> "CommentByLineComment"
    "editor.action.rename" -> "RenameElement"
    "editor.action.revealDefinition" -> "GotoDeclaration"
    "editor.action.selectHighlights" -> "SelectAllOccurrences"
    "editor.action.startFindReplaceAction" -> "Replace"
    "editor.action.triggerParameterHints" -> "ParameterInfo"
    "editor.debug.action.toggleBreakpoint" -> "ToggleLineBreakpoint"
    "editor.fold" -> "CollapseRegion"
    "editor.foldAll" -> "CollapseAllRegions"
    "editor.foldRecursively" -> "CollapseRegionRecursively"
    "editor.unfold" -> "ExpandRegion"
    "editor.unfoldAll" -> "ExpandAllRegions"
    "editor.unfoldRecursively" -> "ExpandRegionRecursively"
    "markdown.showPreview" -> "org.intellij.plugins.markdown.ui.actions.editorLayout.PreviewOnlyLayoutChangeAction"
    "markdown.showPreviewToSide" -> "org.intellij.plugins.markdown.ui.actions.editorLayout.EditorAndPreviewLayoutChangeAction"
    "redo" -> "\$Redo"
    "scrollLineDown" -> "EditorScrollDown"
    "scrollLineUp" -> "EditorScrollUp"
    "scrollPageDown" -> "ScrollPane-scrollDown"
    "scrollPageUp" -> "ScrollPane-scrollUp"
    "undo" -> "\$Undo"
    "workbench.action.closeActiveEditor" -> "CloseContent"
    "workbench.action.closeAllEditors" -> "CloseAllEditors"
    "workbench.action.closeFolder" -> "CloseProject"
    "workbench.action.debug.run" -> "Run"
    "workbench.action.debug.start" -> "Debug"
    "workbench.action.debug.stepInto" -> "StepInto"
    "workbench.action.debug.stepOut" -> "StepOut"
    "workbench.action.debug.stepOver" -> "StepOver"
    "workbench.action.files.newUntitledFile" -> "FileChooser.NewFile"
    "workbench.action.files.openFileFolder" -> "OpenFile"
    "workbench.action.files.revealActiveFileInWindows" -> "RevealIn"
    "workbench.action.files.save" -> "SaveAll"
    "workbench.action.files.saveAll" -> "SaveAll"
    "workbench.action.files.showOpenedFileInNewWindow" -> "EditSourceInNewWindow"
    "workbench.action.gotoLine" -> "GotoLine"
    "workbench.action.navigateBack" -> "Back"
    "workbench.action.navigateForward" -> "Forward"
    "workbench.action.openSettings" -> "ShowSettings"
    "workbench.action.output.toggleOutput" -> "ActivateRunToolWindow"
    "workbench.action.quickOpen" -> "GotoFile"
    "workbench.action.reopenClosedEditor" -> "ReopenClosedTab"
    "workbench.action.replaceInFiles" -> "ReplaceInPath"
    "workbench.action.selectTheme" -> "QuickChangeScheme"
    "workbench.action.showAllSymbols" -> "GotoSymbol"
    "workbench.action.splitEditor" -> "SplitVertically"
    "workbench.action.tasks.build" -> "CompileDirty"
    "workbench.action.terminal.toggleTerminal" -> "ActivateTerminalToolWindow"
    "workbench.action.toggleSidebarVisibility" -> "HideSideWindows"
    "workbench.action.toggleZenMode" -> "ToggleDistractionFreeMode"
    "workbench.action.zoomIn" -> "EditorIncreaseFontSize"
    "workbench.action.zoomOut" -> "EditorDecreaseFontSize"
    "workbench.action.zoomReset" -> "EditorResetFontSize"
    "workbench.view.debug" -> "ActivateDebugToolWindow"
    "workbench.view.explorer" -> "ActivateProjectToolWindow"
    "workbench.view.extensions" -> "WelcomeScreen.Plugins"
    "workbench.view.scm" -> "ActivateVersionControlToolWindow"
    else -> null
  }

  fun shortcutMap(shortcut: String): String = when (shortcut) {
    "SHIFT" -> "shift"
    "ALT" -> "alt"
    "CMD" -> "meta"
    "CTRL" -> "ctrl"
    "-" -> "MINUS"
    "=" -> "EQUALS"
    "BACKSPACE" -> "BACK_SPACE"
    "," -> "COMMA"
    ";" -> "SEMICOLON"
    "." -> "PERIOD"
    "/" -> "SLASH"
    "\\" -> "BACK_SLASH"
    "PAGEDOWN" -> "PAGE_DOWN"
    "PAGEUP" -> "PAGE_UP"
    "[" -> "OPEN_BRACKET"
    "]" -> "CLOSE_BRACKET"
    "'" -> "AMPERSAND"
    else -> shortcut
  }
}